package com.team.employment.web.admin.custom.config;

import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.security.SecurityRequirement;
import io.swagger.v3.oas.models.security.SecurityScheme;
import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;

@Configuration
@Profile("dev")
public class Knife4jConfiguration {

    @Bean
    public OpenAPI customOpenAPI() {

        return new OpenAPI()
                .components(new Components()
                        .addSecuritySchemes("Authorization",
                                new SecurityScheme()
                                        .type(SecurityScheme.Type.HTTP)
                                        .scheme("bearer")
                                        .bearerFormat("JWT")
                        ))
                .addSecurityItem(new SecurityRequirement().addList("Authorization"))
                .info(
                    new Info()
                        .title("后台管理系统API")
                        .version("1.0")
                        .description("后台管理系统API"));
    }

    @Bean
    public GroupedOpenApi userAPI() {

        return GroupedOpenApi.builder().group("用户管理模块").
                pathsToMatch(
                       "/admin/userAction/**",
                        "/admin/userInfo/**",
                        "/admin/userType/**"
                ).
                build();
    }

    @Bean
    public GroupedOpenApi companyAPI() {

        return GroupedOpenApi.builder().group("企业管理模块").
                pathsToMatch(
                        "/admin/companyInfo/**",
                        "/admin/companyRelated/**",
                        "/admin/companyState/**"
                ).
                build();
    }



    @Bean
    public GroupedOpenApi statutoryAPI() {

        return GroupedOpenApi.builder().group("法定人管理模块").
                pathsToMatch(
                        "/admin/statutoryInfo/**",
                        "/admin/statutoryRelated/**",
                        "/admin/statutoryState/**"
                ).build();
    }
    @Bean
    public GroupedOpenApi resumeAPI() {
        return GroupedOpenApi.builder().group("简历管理模块").
                pathsToMatch(
                        "/admin/resumeAction/**",
                        "/admin/resumeState/**"
                ).build();
    }
    @Bean
    public GroupedOpenApi recruitmentAPI() {
        return GroupedOpenApi.builder().group("招聘管理模块").
                pathsToMatch(
                        "/admin/recruitmentInfo/**",
                        "/admin/recruitmentState/**"
                ).build();
    }
    @Bean
    public GroupedOpenApi positionAPI() {
        return GroupedOpenApi.builder().group("职位分类管理模块").
                pathsToMatch(
                        "/admin/position/**",
                        "/admin/positionSecond/**",
                        "/admin/positionThree/**"
                ).build();
    }
    @Bean
    public GroupedOpenApi communalAPI() {
        return GroupedOpenApi.builder().group("公共数据模块").
                pathsToMatch(
                        "/admin/benefitInfo/**",
                        "/admin/region/**",
                        "/admin/degreeInfo/**",
                        "/admin/isStatus/**",
                        "/admin/isRelease/**",
                        "/admin/fileUpload"


                ).build();
    }

}